#include <Arduino.h>
#include<MatrixLed.h>
#include<onebutton.h>

#define din 5
#define cs 4
#define clk 3
#define rightPIN 6
#define leftPIN 7
#define firePIN 9

byte location = 0;
MatrixLed mc= MatrixLed(din,clk,cs);
OneButton right(rightPIN,true);
OneButton left(leftPIN,true);
OneButton fire(firePIN,true);

void moveright(){
  if(location<=6)
    location++;
  mc.setplane(location);
  Serial.println("right");
}
void moveleft()
{
  if(location>=1)
    location--;
  mc.setplane(location);
  Serial.println("left");
}
void getfired()
{
  mc.getfire();
  Serial.println("fire");
}
void setup() {
  // put your setup code here, to run once:
  mc.init();
  right.attachClick(moveright);
  left.attachClick(moveleft); 
  fire.attachClick(getfired);
  Serial.begin(9600);
  
}

void loop() {
  // put your main code here, to run repeatedly:
  mc.display();
  right.tick();
  left.tick();
  fire.tick();
}